package com.ming.redis.service.redisListener;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;

import java.util.concurrent.TimeUnit;


/**
 * @Auther: tangC
 * @Date: 2020/7/7 15:41
 * @Description:
 */
@Slf4j
public class QueueListener2 {

    @Autowired
    RedisTemplate redisTemplate;


    public void test() {
        new Thread(() -> {
            while (true) {
                try {
                    Object sad = redisTemplate.opsForList().rightPop("test", Integer.MAX_VALUE, TimeUnit.DAYS);
                    log.info(sad.toString() + "线程2");
                } catch (Exception e) {
                    log.error("获取数据出错");
                }
            }
        }).start();

    }

}
